package com.skyz.wrap.dialog;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;

import com.skyz.base.dialog.BaseDialogFragment;
import com.skyz.wrap.R;

public class ImageDialogFragment extends BaseDialogFragment {

    public static ImageDialogFragment showDialogFragment(@NonNull FragmentManager manager, int res, View.OnClickListener listener) {
        ImageDialogFragment loadingDialogFragment = new ImageDialogFragment();
        loadingDialogFragment.config(res);
        loadingDialogFragment.show(manager, null);
        return loadingDialogFragment;
    }

    int imgRes;

    private void config(int data) {
        this.imgRes = data;
    }


    private ImageDialogFragment() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_fragment_img;
    }

    private ImageView imageView;

    @Override
    protected void onLayoutInflated(View view) {
        imageView = view.findViewById(R.id.imageView);
        imageView.setImageResource(imgRes);
        setDialogCancelable(true);
    }

    @Override
    protected WindowManager.LayoutParams initLayoutParams(WindowManager.LayoutParams layoutParams) {
        layoutParams.gravity = Gravity.CENTER;
        layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        return layoutParams;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }
}
